package com.example.untitled;

import android.content.Intent;
import android.os.Bundle;


import java.util.Objects;

import io.flutter.embedding.android.FlutterActivity;
import io.flutter.embedding.engine.FlutterEngine;
import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugins.GeneratedPluginRegistrant;

public class MainActivity extends FlutterActivity {

    private static final String CHANNEL = "demo.plugin";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // 自定义插件
        //getFlutterEngine().getDartExecutor().getBinaryMessenger()
        new MethodChannel(Objects.requireNonNull(getFlutterEngine()).getDartExecutor().getBinaryMessenger(), CHANNEL)
                .setMethodCallHandler((call, result) -> {
            if (call.method.equals("interaction")) {
                Intent intent = new Intent(MainActivity.this, AndroidActivity.class);
                startActivity(intent);
                result.success("success");
            } else {
                result.notImplemented();
            }
        });

        GeneratedPluginRegistrant.registerWith(new FlutterEngine(this));

    }

}
